package cvsexercise13;

/* import statements for JUnit functionality */
import static org.junit.Assert.*;
import org.junit.Test;

public class RectangleTest {
	
	@Test
	public void testGetColour() {
		
		Rectangle rect = new Rectangle("white", 1.0, 1.0);
		
		/* Use assertEquals to test the object is "white" - unit test should pass */
		assertEquals("white", rect.getColour());
		
		/* Use assertEquals to test the object is "red" - unit test should fail */
		assertEquals("red", rect.getColour());
	}
	
	@Test
	public void testGetArea() {
		
		Rectangle rect = new Rectangle("red", 2.0, 1.0);
		
		/* Use assertEquals to test the area <= 2.0 - unit test should pass */
		assertEquals(1.0, rect.getArea(), 1.0);
		
		/* Use assertEquals to test the area <= 1.5 - unit test should fail */
		assertEquals(1.0, rect.getArea(), 0.5);
	}
	
	@Test
	public void testExists() {
		
		Rectangle rect = null;
		
		/* Use assertNull to test object has not been instantiated */
		assertNull(rect);
		
		/* Use assertNotNull to test object has been instantiated */
		assertNotNull(rect);
	}
	
	@Test
	public void testEquality() {
		
		Rectangle rect1 = new Rectangle("red", 1.0, 1.0);
		Rectangle rect2 = rect1;
		Shape shape1 = rect2;
		
		/* Use assertSame to test if references point to same object */
		assertSame(shape1, rect1);
	}
}
